Here is my solution:
I have assumed that all the cells are numbered i.e distinct and that the 4 letters are placed in the matrix according to the given conditions.
Choose one of the two: a or b in :2
Choose one of the 16 cells to place the first letter : 16
Place the other letter of the same kind in a cell not sharing a row or column with the first: 9
Now place the remaining two letters. Three cases are possible
1) the third letter shares a cell AND column with the two letters already placed: 2 cells
The fourth letter can then be placed in one of 9 cells.
2) shares a cell OR column, but not both: 8 cells, fourth placed in one of 8 cells
3) does not share cell or column : 4 cells, fourth goes to one of 7 cells
Total number of ways= 2*16*9*[2*9+8*8+4*7] = 31680