That is the fundamental question, isn’t it?
I think the basic answer is that any church teaching is primarily an extrapolation from public revelation - that is, scripture and previous definitive teachings of the church. Secondarily, it can also make use of non-definitive teaching and/or opinions from other theologians (including ancient authorities like the church fathers) when building a case; and sometimes material contained in private revelation, although the latter cannot be the
only source when constructing a definitive teaching. Simple teaching becomes doctrine and perhaps dogmatic or otherwise infallible teaching over time, when it’s undergone proper scrutiny and has been appropriately promulgated.
As to ‘how do we know’ what the souls in purgatory can do in terms of prayer: we don’t. That’s why the subject has not yet risen to the level of official teaching, and remains in the realm of theological opinion.
The volume by Ott that I quoted above states that the ability of the souls in purgatory to pray for others - including other souls in purgatory, but perhaps not for oneself, since that is not specified - was recorded at the provincial synods of Vienna (1858) and Utrecht (1865). That in and of itself means only that a theological opinion was expressed by the synods, and this does not rise to authoritative or universal teaching.
Hope this helps to some degree. If I’m misunderstanding your questions I apologise.