Philosophy in general is the rational investigation of truth. Religion often makes the same kind of truth claims but doesn't claim to base it on reason or rationality, but instead it is based on other things like faith.
Religion is a belief in a God who you would worship of it as the creator of the universe without questioning. And philosophy is a pursuit of wisdom by intellectual search and logical reasoning.
Children will associate there unacceptable behaviour with getting spanked, and the purpose is to dissuade them from partaking in that behaviour in the future.