While it is possible to use MongoDB as a traditional database, and put your own server between the database and the client-side application logic, it is also possible to allow the client-side application to directly access the database with MongoDB Realm.
You could do the same with Firebase: you can disallow all access from client-side applications in security rules and then only use your own server-code to access the database.
Neither approach is pertinently better than the other, so you should pick what's the best fit for your use-case, what you're most comfortable with, or what you want to learn more about.