It's also a matter of surface area & oxygenation vs water volume. That's especially in very tall tanks with a small footprint with insuffient water movement top to bottom & at the surface. A standard 10 inch x 20 x 12 10g tank will support a similar fish load as a 20g tall (like 2 10g stacked on top of each other). There are many "non-standard" tanks that may look cool but can have unexpected issues.
But many things can affect stocking as others have said. I happen to love bottom feeders, so it's more about a tank's footprint but also oxygenation for me.
That's why we ask. We have many different experiences with various species & tank sizes.
A bow front (if I understand the dimensions of
your 40g) sounds like it would be ok for the species you listed. My only hesitation is with all the low level/bottom fish. Rams (a male & female pair?), kuhlis,(6-8?) & a pleco (a bristle nose? clown?). With enough caves/plants/hiding places that could be fine. Bolivians are, for cichlids, not too aggressive. But if they breed they'll need a little more room/caves for egg laying & fry moving & care. Other fish will eat eggs & smaller fry if they can...& that's ok...unless you hope for more.

that's partly why some of us have several tanks but also so we can keep incompatible species. It's an addictive hobby, lol.
AND since nobody asked yet, I will. How will you cycle the new tank BEFORE you get fish? This is absolutely
key to starting a new tank. It can take 4-6+ weeks to grow the beneficial bacteria for a healthy tank. Read the sticky at the top of the newbie forum. This is a VERY IMPORTANT step, don't dismiss it. There are ways to "jump start" the cycle but read lots BEFORE you try these. Many people get into bad trouble by only doing part of what is required.
Really, we all wish you good luck! But there are several ways to do all kinds of tanks. Let us help you, learn for our experiences & mistakes. & be patient with our many quesions...there will be more!