You can analyze any waveform, as long as the maximum frequency present in the waveform is less than 1/2 the sampling frequency. For a square wave, that is never true, so you will see false peaks due to aliasing.
A good antialiasing filter with a hard cutoff of no more than 1/2 the sample frequency is always recommended if you want to avoid such artifacts.