We see the afternoon/morning/evening as periods of time so we say
In the morning for example.
However, a rainy afternoon, the word rainy changes the emphasis and its better to say on.
It’s a very small difference and hard to give a clearer explanation than that.
Hope it helps.
🙏