In تَعَلَّمُوا الْعِلْمَ، وَعَلِّمُوهُ النَّاسَ, the instruction to learn precedes the instruction to teach. The suffix ـهُ refers to الْعِلْمَ. In الْفَرَائِضَ … وَعَلِّمُوهَا, ـهَا refers back to the plural noun.
Good teaching includes awareness of one’s limits: explain what one knows accurately, investigate complex cases, and consult qualified people where necessary.
For example, a Qur’an teacher should be competent in recitation; detailed inheritance disputes should not be taught confidently without preparation.