Un cuadrado tiene cuatro lados.

English Translation

A square has four sides.

Could I use “costados” in this context?

Hmm. You’d be understood, of course, but mathematical terminology tends to be fixed. I don’t think I’ve ever seen ‘costado’ used in this context.

Okay, I think I was inspired by the sentence “Es un artista por los cuatro costados.” (He is an artist through and through), in Spanish Idioms.