You immediately gain water weight, not fat. You obviously can’t gain pounds of fat just because you ate some carbs more or some problematic substance… Something changes in your body, that happens but making fat from almost nothing isn’t possible.
It’s interesting that our body makes its choice and reacts quite differently after some weeks and months on a diet it prefers. I don’t talk about the first crazy day, right out of keto, our physiologically insulin resistant body (I hope I wrote it right, I’ve read about this in my own language, not in English but it should be okay) gets confused, it must change its behavior (not like I have any problem with it if I don’t go super crazy and I never did that immediately after keto. but it would be normal to feel bad). But I can’t handle carbs very well even if I am not in ketosis since a very, very long time. I had that before keto too, I went low-carb and high-carb for more than 1-2 days became impossible for me. (I never felt great on a carby diet but I was okay and healthy enough and had no idea there is something better.)
Of course, it’s individual and not always the same for the same person either. Our sweet spot (ideal carbs range) is personal. I don’t need keto to feel okay (less carbs is still better though) but I can’t go too high for long without dire consequences. Others have problems way easier and earlier. Some people go and eat high-carb for months and nothing pulls them back, they just gain fat, usually. I would feel I’m dying after a week (but considering what some people eat? after a day. my body is forgiving but knows what it wants and I like that).