There are two considerations for building encounters. The first is CR the second is the XP budget.
To build an encounter, the first thing you decide is how hard you want the encounter to be. You have a range to select from. From Easy to Deadly. This provides you with the XP budget for the encounter. A same CR monster will likely consume the whole CR budget for a moderate encounter, so keep that in mind.
The next thing you need to consider is the overall adventure context. If you're designing a single day dungeon, then you'll want to have a look at the table that indicates how much the XP budget for an adventuring day is. Make sure you divide that properly so that you're not over taxing your PCs on a day (or at least you know *how big of a challenge it is for them). At Level 5 you should be aiming for 3500 XP per player on your average day. That's 7 moderate encounter, or more easy ones or fewer harder ones.
It's also important to note that when you mix multiples of the same creature, you add an XP multiplier to calculate the difficulty. So if you have 2 CR 1/4 Goblins, they are worth 100 XP, but they make the challenge of the encounter equivalent to 150XP.
With this in mind, you can build your encounters. A CR 5 monster is worth 1800 XP, that's a bit less than a moderate encounter for 4 PCs and a bit less than a hard one for 3 Pcs. Add in some secondary creatures as minions and you would have your XP budget for a moderate/hard encounter.
If you wanted to design an easy encounter, or an encounter with a lot more creatures, select lower CR creatures to populate it.