I fried my Raspberry Pi while using L298N but I don't understand why
As Oldfart mentioned, the datasheet reveals that the +5v is not optional; it is the logic supply of the L298 chip. It is very likely that your raspberry pi was sinking/sourcing way more current than it could handle.

The datasheet does not define the behavior of the chip when the logic supply is not connected but I think it's safe to assume that this caused your RPi to let out the magic smoke.