How Many Times can You Format an HDD or SSD?
The only matters of concern are:
Are you performing a quick format or a full format? A quick format just overwrites the core file system data structures with a new file system and usually only involves a few megabytes of writes (compared to many gigabytes or terabytes of total disk space). A full format only writes a small amount of data, but reads from every part of the disk to make sure the disk is okay.
Usually after you format a disk (if it is your primary storage), you are going to install an operating system on it. This usually causes 2 – 25 GB of disk writes at first, plus another several gigabytes to install programs and updates.
All this writing of new data (which will vary in quantity depending on what type of format you performed and what you are going to do after you format it) can cause wear on SSDs and, to a lesser degree, the mechanical parts of HDDs. The amount of wear is proportional to the amount of data that is being read and/or written, with SSDs largely unaffected by reads, but HDDs being affected roughly the same by reads and writes.
I am not going to delve into the topic of disk endurance and how certain quantities and frequencies of reads and writes affect the endurance (wear level) of different types of disks. This is a very complex topic that is completely independent from the subject of disk formatting.
Just know that the operation of reinstalling Windows on a hard-disk drive is basically doing the same thing to your disk as copying several gigabytes of movies or pictures or music. Just the act of using a computer involves very frequent disk reads and writes.
The only difference is that formatting a disk and then using it often incurs a fairly large amount of reads and writes compared to what a typical user might do in a day.
Analogy: If you normally drive 8 km to work every day in your car and then take a holiday trip of 200 km, this is fundamentally the same action, you are just driving further. Formatting causes more wear on your disk, just like driving further causes more wear on your car.
If you want to know how reading and writing data impacts the endurance of your particular type of disk, you can either ask a new question, search for existing questions, or use Google to find this information.