Spot all (anti)diagonals with duplicated values
R, 92 86 82 78 bytes



function(m,x=row(m),y=col(m),`|`=split,`^`=Map)sum(max^table^c(m|x-y,m|x+y)&gt;1)


Try it online!

Explanation

First, we declare additional variables \$x\$  and \$y\$ that stand for row and column indices, respectively. Then we can delineate the diagonals and anti-diagonals by taking their difference and sum. E.g., for a 4x4 matrix:

\$x-y\$ gives:

0 -1 -2 -3
 1  0 -1 -2
 2  1  0 -1
 3  2  1  0

\$x+y\$ gives:

2  3  4  5
 3  4  5  6
 4  5  6  7
 5  6  7  8

Now split(m, x-y) and split(m, x+y) produce the actual lists of diagonals and anti-diagonals, which we join together.

Finally, we count the entries of the resulting list where duplicates are present.

Thanks for bytes saved:

-4 by CriminallyVulgar
-4 by digEmAll