$n\textrm{ Hz}$ waveform sampled at $m\textrm{ Hz}$ per second
The basic square wave function signal.square() has a period of 2*pi. Multiplying each time by 2*pi*f is a way of stretching the wave along the time axis to get a wave with a period of 1/f.
To understand what the sample rate refers to, look at the first line:

t=np.linspace(0,1,500,endpoint=False)


If you look at the numpy documentation for this function, you'll see this creates a list of 500 evenly spaced numbers between 0 and 1. This is an array of times. When you then call the signal.square() function with this array, it returns an array of points on the square wave for each of those times. Thus you have sampled the square wave at 500Hz for 1 second.