The setting for If isn't anywhere particular while "Just the Two of Us" is switching from place to place as time goes by. First in the hospital, to riding in the car, and then to their home. Both the poem and the song's prompt is the same because both of the writers want what's best for their kids, so they're trying to teach them and give advice. Their audience is their sons. The speaker for both, the poem and the song, are the writers and it's in first person point of view. The tone is a fatherly helpful voice.
In the poem If, Kipling is trying to distinguish between the two types of people there