So here many websites says $$\operatorname{trace}(AB) =\operatorname{trace}(A)\cdot\operatorname{trace}(B).$$ But when I took two examples randomly and check it doesn't give equal answer. So it should be equal or not equal all the time? I am adding a picture to make it clear

The trace of $AB$, in general, is not equal to the product of the trace of $A$ and the trace of $B$, if you mean $a_{1,1} + a_{2,2} + \dots + a_{n,n}$ by "the trace of $A = [a_{i,j}]_{n \times n}$". However, it is true that the trace of $AB$ equals that of $BA$.
I would like to list some facts for your reference: