The different mechanisms become clear when the examples are classified:
1. وَكَانَتْ مِنَ الْقَانِتِينَ — a female individual is included in a broader group expressed by a masculine plural.
2. بَلْ أَنْتُمْ قَوْمٌ تَجْهَلُونَ — second-person meaning prevails over the overt noun’s formal perspective.
3. الْأَبَوَانِ — a single term gives a dual naming the father and mother.
4. الْقَمَرَانِ — one member’s name forms a dual for the sun and moon.
Do not force every example into precisely the same grammatical explanation; locate the predominance in each.