You're absolutely right that we can, but the issue is that most teams are too large or too disorganised to share complex codebases, so they choose to do a hard division: splitting the code itself.
Here's an argument that I love: Microservices and microfrontends are (most of the time) a failure of encapsulation [1].
Of course there are other benefits, such as separate deployment processes and ability to use different frameworks.
[1] https://michaelfeathers.silvrback.com/microservices-and-the-...