Disks have spare sectors and will silently use them to replace bad ones. If a failing sector is found, disk's firmware will try to recover it and write whatever was read into a spare sector. This sector is then logically remapped into failed sector's address. Under normal operation the computer won't notice a difference. You may notice it, however, because recovering a sector can take a long time. That's why failing disks slow computers down significantly.
Number of reallocated sectors should be reported by the disk in its SMART data. If you're seeing bad sectors in surface scans, it means the disk ran out of spare sectors. This will also be indicated in SMART. Such disk can fail anytime and should not be trusted.
SSDs are an interesting case, because in addition to excluding bad sectors, they cycle good sectors all the time. That's because SSD blocks (storage units consisting of multiple sectors) will endure a finite number of writes. Once a certain threshold is reached, a whole block will become read-only. To avoid uneven wear of blocks and to improve performance, SSD controller will always try to write to a least worn unused block. If just a few sectors are to be updated, it will read original block, edit those sectors in memory, write result to a new block, remap the original one and mark it as unused. Basically in an SSD blocks of sectors are remapped all the time, their logical addresses are temporary - unlike with HDD sectors, when sectors are remapped only due to a failure.