The key is to look at the context. Here is a brief outline of Paul's argument:
Galatians 5:16–24 (LEB)
16 But I say, live by the Spirit, and you will never carry out the
desire of the flesh.
17 For the flesh desires against the Spirit, and the Spirit against
the flesh, for these are in opposition to one another, so that
whatever you want, you may not do these things.
18 But if you are led by the Spirit, you are not under the law.
19 Now the deeds of the flesh are evident, which are sexual
immorality[...] selfish ambition [...]
22 But the fruit of the Spirit is love, joy, peace, [..]
24 Now those ⌊who belong to Christ⌋ have crucified the flesh together
with its feelings and its desires.
Notice that Paul contrasts the works of the flesh (which are evident) with the fruit of the spirit (that is inward and invisible) - the observable, emotional, works of the flesh with the invisible, spiritual works of the Spirit.
Those who are carnal, who only see the flesh, will only see the works of the flesh, both in themselves and in everyone else (they will project their own carnal nature onto those who they judge according to the flesh - Romans 2.1). Those who are spiritual will bear the fruit of the spirit.
We are both flesh and spirit, with the spirit at war with the flesh, so that we cannot accomplish what we want - e.g. the spirit frustrates the ambitions of flesh, causing our plans to fail, even as the flesh poisons our good works, so that when we try to do good, it is tainted with self-glorification (Romans 7.21). As an example of this selfish ambition, consider the selfish prayer in Luke 18:
The Pharisee stood and prayed thus with himself, God, I thank thee, that I am not as other men are, extortioners, unjust, adulterers, or even as this publican. Luke 18.11 KJV
Which is identical to the selfish prayer in the Talmud, y. Ber. 4:2, I.1.B:
[B] And when he exits [the study hall] what does he say? “I give
thanks to thee, Lord my God, God of my fathers, that you cast my lot
with those who sit in the study hall and the synagogues, and you did
not cast my lot with those who sit in the theaters and circuses. For I
toil and they toil. I arise early and they arise early. I toil so that
I shall inherit [a share of] paradise [in the world to come] and they
toil [and shall end up] in a pit of destruction.
The moment the prayer shifts from focusing on God to focusing on the self or assessing the self, it became tainted with selfish ambition.
But the spiritual person - that is, the person who pays all attention to God and not to himself or others - when he does do good, is not even aware of what he is doing - his works follow him [Rev 14.13], behind him, out of his own sight and out of his awareness (Matt 6.3, Matt 25.37-39).
Therefore Paul urges his followers to crucify the flesh, with its feelings and desires, as nothing good can come of dwelling on yourself or others, or anything else that happens on the earth. Instead we are to keep our mind on "things above" (Col 3.2), listening and waiting on God with faith and patience.
There is only one area where Paul tells us to focus on ourselves, and that is to examine ourselves to know that God is in us (2 Cor 13.5). Once that examination is complete and the issue is settled, then there should be no further self-examination or self-judgment (1 Cor 4.3). This is why, in the famous "Fool's speech" (2 Cor 11.22-12.10) where Paul was assessing himself for the purpose of teaching a lesson, he pointed out that he was acting like a fool repeatedly by even assessing himself at all. Moreover he was clear that he resolved to judge no one after the flesh (after what can be seen) in 2 Cor 5.16.
Similarly, we cannot focus on others either, because in order to determine whether someone else has selfish ambition or whether they are bearing the fruit of the spirit, one must have knowledge of their heart. That is, Paul's verse is not supposed to be a weapon to judge other people (which would miss the whole point) allowing the Galatians to have one more accusation to levy against each other, but is rather a warning to the Galatians to keep their own minds focused on God only. Do not judge other people based on what you can see with your eyes, and do not judge yourself at all. Keep your mind fixed solely on God.
Therefore "selfish ambition" - like all the other works of the flesh - is the result of keeping your heart focused on something on the earth, something that can be observed, rather than on heavenly things.