Why people always take 4.7kΩ and not, say 5kΩ ?
Well, because there are some standard values (called E-values) for resistors they are manufactured. The reason behind this is easy: this way you can create any resistance value with the right combination of these.
How do I calculate the time constant for the same circuit, but with a square (not sine) input?
A square wave is a combination of infinite sinusoidals (see Fourier transformation) so you won't get an exact expression for any calculation regarding frequency, you can only calculate things for different sinusoidal components of the square wave