You can use Ansible to provision servers, it works, but if you do that a lot it's better to use Terraform. With Ansible you are a bit at a lower level and you need to manage the state of your system yourself. It's fine for 4 permanent VMs but not for more complicated infrastructures.
I'm not very familiar with Ansible but consider it to be somewhat interchangeable with Puppet (which I use extensively at work). You can certainly use Puppet to manage thousands of hosts but it entirely depends on other practices and technologies (an external node classifier in Puppet's case) to keep things manageable. I assume the same is true for Ansible.
Ansible is agentless, so the management of endpoints is entirely based on your server doing the scripting. It can use a static inventory file (text) or a dynamic one which can be served from anywhere (eg, sql query). Whenever you write playbooks you target groups of hosts based on tagging that’s done through inventory.