If you replace a repeater hub (long obsolete, of course) by a switch, you indeed break the larger collision domain into many smaller ones - one on each switch port when half duplex mode is used. Full-duplex links (to a FDX-capable NIC or another switch) are generally collision-free and don't take part in any collision domain.
The main point with switches is that they buffer network frames. That enables a switch to receive a frame at any time and then forward it later when the egress link is idle. This decoupling of receive and transmit operations enables a network that works with flows that are largely independent from each other and only compete for link bandwidth (assuming FDX links throughout).
This is in stark contrast to repeater hubs that repeat incoming bits as they are received. A hub can't buffer anything - when a single transmission is already in progress, a second transmission attempt cannot the repeated at the same time and causes a collision. The collision needs to disrupt reception on the ingress interface since data is already garbled, so the hub propagates it across all ports, including the one back to the source.
This way, all nodes connected to a hub (or potentially chained hubs) form a single, common collision domain. Only a single node at any time can transmit.
A switch connected to a hub (or another non full-duplex capable device) can still use half-duplex mode on any of its ports but due to the buffering between the ports, any collision will not propagate across the switch - the switch will simply retransmit the buffered frame later on. Therefore, a switch segregates collision domains or removes them completely on full-duplex links.
Note that half-duplex Ethernet and hubs are very much things of the past and only interesting for historical reasons or under very specific circumstances. Practically all Gigabit and (by standard) faster Ethernet links have dropped support for half-duplex communication and you need to use switched or point-to-point connections exclusively.