There are 4 cases to consider:
A and B are the same person
(This is possible, if for example, the grid is a 1x1 grid). I this case A and B are the same height.
A and B are in the same row
Since A comes from a group of people who are the tallest in their rows, A must be the tallest person in his row. Thus, if B is in the same row, A is taller.
A and B are in the same column
Since B comes from a group of people who are the shortest in their respective columns, B must be the shortest in his column. Thus, if A is in the same column, A must be taller.
A and B are in different rows and columns
For this case, imagene a person C, who is in the same row as A, and in the same column as B. C must be shorter than A, since A is the tallest in his row. C must be taller than B since B is the shortest in his column. Thus, since A is taller than C who is taller than B, A must be taller than B.
As you see in all cases but the specialized case where A and B are the same person, A must be the taller of the two.