Can somebody explain why there cannot be any triangles or squares in a Moore graph with diameter 2? This was stated without proof in my class.
I don't know which definition you're using, but on Wikipedia, a useful one is that a Moore graph is a graph $G$ of diameter $k$ and girth $2k + 1$.
That means if $k = 2$, then the smallest cycle in $G$ has $5$ vertices. Having a triangle or a square would contradict that.