What makes flashing ROMs risky? I would like to play with developing Android ROMs for learning purposes and for maybe I can fork my current ROM and change interesting stuff in it.

I would rather be not happy at all with a bricked device, but how likely is that to happen?

As far as I know,  if the bootloader is untouched, flashing even garbage should leave the device repairable since one can still go in flash mode and flash a new rom because the bootloader is fine. Right?

Also I presume hardware can't really be damaged by bad software, can it? (I need a compelling reason if you say yes)

So theoretically, my device can't really break by flashing and trying a custom ROM even if its faulty or even there happens an error during flash, no? (given I don't touch the bootloader)
As Death Mask Salesman pointed out, you need to be sure that the flashing process itself doesn't overwrite the partition table or the bootloader. But even if the flashing itself doesn't cause an unrecoverable problem, it's still possible for a broken ROM to break the hardware of the phone.

Here's a real-life example from when I worked on ROM integration. One of my colleagues bricked the development hardware we were working on by flashing a ROM where the kernel had had the CPU throttling and thermal cut-out disabled. The development board ran with the CPU at max speed for a couple of minutes and then melted the SoC.

Hardware can very much be damaged by drivers that have been edited or compiled with the wrong options. Overclocking the CPU or GPU (a popular feature in custom ROMs) carries its own risk of overheating - especially if your phone is slightly off-spec. Some kinds of screen backlight can be damaged by running them too hard, which the driver prevents in normal use. Also, some components such as NFC chips and secure elements have anti-tampering "fuses" - if you blow one of those by accident (by writing to the wrong hardware register), it might be irreversible.

This is why rooting or flashing a custom ROM voids the warranty.