In what form should I put nonstative verbs with "when"? E.g.,
(1) You have to be careful when you cut a cake.
(2) You have to be careful when you are cutting a cake.
Is there a difference between the two? Do they both mean the same thing?
Yes, these both essentially mean the same thing & could be used interchangeably.
I suppose there are subtle nuances if you overthink it though, so ... :)
The first sentence sounds a bit more like it refers to the entire act and ceremony of cake cutting: preparing to cut, planning where/how to cut so the pieces are equally sized, and then the actual act of cutting. It's like a rule for a student of the cake-cutting process.
The second sentence sounds more like it refers only to the specific time when you're in the act of cutting. It's like a gentle reminder that the knife is sharp, so be careful.
Another way it would be clearly different is when referring to a specific cake:
You have to be careful when you cut the cake (because it's the only one!).
You have to be careful when you cut a cake (because the knife is sharp).