The reason for adding strong acids or bases to water rather than the other way around is that the dissolution/reaction of these compounds with water tends to be very exothermic and can result in splattering or even boiling of the strong acid or base, particularly if water is added to the concentrated acid or base.
On the other hand, if you slowly add the acid or base to water, you will never have a concentrated acid or base present to splatter as it will be rapidly diluted by the much larger amount of water. Even if you accidentally add the acid or base too quickly, at least the splattering will primarily be of water or dilute acid/base rather than splattering concentrated strong acid or base. It is still important to do the addition slowly so that you only slowly increase the acidity/basicity of the solution. This way, the rate of reaction (and thus also the heat evolution) will happen at a safe level and greatly reduce the risk of splattering.
As a side note, this concept does not only apply to the addition of strong acids and bases to water. While mixing any chemical reagents (unless otherwise specified of course), you should add the more reactive or concentrated solution to the less reactive or more dilute solution, for the same reasons as described for the addition of strong acids and bases to water.