The TLDR is any time you stumble onto a peer, you hold onto them. Once you hit some limit then you remove the “least useful” peers until you’re within the acceptable range of connections.
There are a number of ways this could be done, including:
DHT
Being a DHT client (the default with IPFS desktop) will cause you to connect to a number of DHT nodes in order to be able to look up data efficiently
Being a DHT server (the default with standard go-ipfs if your machine is reachable on the public internet) will cause you to lookup nodes in order to efficiently perform lookups and give peers good responses, and will also receive connections from peers looking for data in the DHT
MDNS (enabled by default) will connect to all IPFS (or libp2p) MDNS nodes on your local network
Content Providing
Looking for providers of content to download (i.e. via the DHT) will connect you to those providers
If you have content you are advertising, and are publicly reachable then people will find you (i.e. via the DHT) and connect to you
There are more general libp2p filters that can be added if you’re building your own go-ipfs or using it as a library, but those aren’t currently available via the IPFS config. If you have a common use case you’d like bubbled up as a config I’d recommend filing an issue to discuss it
The reason you see less then 10 immediately, then an increase is that the first ~5-10 immediate connections are done to the bootstrapping nodes hardcoded in your config. Then the DHT peer discovery begins and the number of nodes growth organically.