Hubris is the type of pride that gods have to punish. But the real question is how do gods themselves avoid having pride or hubris?
Lucifer was an angel in high authority before God before his fall.
"... an angel of God who was in authority in the presence of God, who rebelled against the Only Begotten Son whom the Father loved ... was thrust down from the presence of God and the Son....
And was called Perdition, for the heavens wept over him—he was Lucifer, a son of the morning.
And we beheld, and lo, he is fallen! is fallen, even a son of the morning!" (D&C 76:25-27)
He may have been equal with Jesus Christ, since they are both referred to as a morning star.
“How you have fallen from the heavens, O morning star, son of the dawn!" (Isaiah 14:12, Gileadi translation)
"I Jesus ... am the root and the offspring of David, and the bright and morning star." (Rev 22:16)
Lucifer fell because he became prideful. That he was in fact better than others, and knew better what they should do than they did. All of which was undoubtedly true, because he had indeed attained a high level of trust from God. But as soon as one takes that true but prideful attitude and actually applies it to control others, one is led into the errors for which Lucifer became Satan.
"because that Satan rebelled against me, and sought to destroy the agency of man, which I, the Lord God, had given him, and also, that I should give unto him mine own power;" (Moses 4:3)
"when we undertake to cover our sins, or to gratify our pride, our vain ambition, or to exercise control or dominion or compulsion upon the souls of the children of men, in any degree of unrighteousness, behold, the heavens withdraw themselves; the Spirit of the Lord is grieved; and when it is withdrawn, Amen to the priesthood or the authority of that man.
... it is the nature and disposition of almost all men, as soon as they get a little authority, as they suppose, they will immediately begin to exercise unrighteous dominion." (D&C 121:37,39)
Thus we see how pride goes before a fall (Prov 16:18). But how does God and other angels avoid that trap? First, let us recognize that our agency is a gift from God (as stated above) which he will not take away except at the final judgment.
"And because that they are redeemed from the fall they have become free forever, knowing good from evil; to act for themselves and not to be acted upon, save it be by the punishment of the law at the great and last day, according to the commandments which God hath given." (2 Nephi 2:26)
But notice that it is the law which punishes and not God. God has given that law, and it is just because it is the law by which he himself lives. He lives according to the golden rule, the second great commandment, and does unto others as he would have them do unto him. While wickedness invariably comes from treating others in ways you would not want them to treat you. And even at the great and last day of judgment, it is not necessary for him to act in order to punish people, for they will recognize his example and authority and accept his judgments upon them.
"Yea, every knee shall bow, and every tongue confess before him. Yea, even at the last day, when all men shall stand to be judged of him, then shall they confess that he is God; then shall they confess, who live without God in the world, that the judgment of an everlasting punishment is just upon them;" (Mosiah 27:31)
Only a few will deny and defy God to his face and suffer God's wrath. But they will have shown by their own actions that they would and have tried to destroy the agency of others, so God is just in doing to them as they would do to others.
"Thus saith the Lord concerning all those who know my power, and have been made partakers thereof, and suffered themselves through the power of the devil to be overcome, and to deny the truth and defy my power—
For they are vessels of wrath, doomed to suffer the wrath of God, with the devil and his angels in eternity;
Having denied the Holy Spirit after having received it, and having denied the Only Begotten Son of the Father," (D&C 76:31,33,35)
Thus the path to avoid hubris is in recognizing the agency of others. Allowing them to taste the bitter that they may learn to choose the good. (Moses 6:55) How far is God willing to allow people to choose evil before stopping them? Satan is the prime example of how far God is willing to let them exercise their agency wrongly.
But God is just and wise and able to make everything right in the end (Rev 21:4). He exercises his power by speaking or commanding, and because we recognize his absolute goodness, we also recognize his absolute authority, and he need only watch until we obey. (Abraham 4:18)
And we can follow God's example in our own lives. Instead of trying to control others, all we have to do is speak the truth, and watch what happens. We may suffer for doing so, but that is also according to God's example.