This is a seemingly unusual action by the Lord, in that Nadab and Abihu had offered incense before the Lord, without provocation from the Lord. It's important to understand that a priest acts for God on behalf of the people. Mal. 2:7,
"For the priest's lips should keep knowledge, and they should seek the
law at his mouth: for he is the messenger of the Lord of hosts".
Therefore, it's important that all what a priest does in his official duties is in response to the Lord, and they are to 'sanctify' themselves(act in a manner reflecting the fear of God and the responsibility that their duties require) before the Lord. Ex. 19:22,
And let the priests also, which come near to the Lord, sanctify
themselves, lest the Lord break forth upon them.
It seems from the passage that they were 'trying out' their priestly duties, without any assignment of them from the Lord, and they were also wearing their priestly attire (vs 5) when they were carried out. But there was another reason that the Lord "broke out' on them, and admonished Aaron in vs. 3,
Then Moses said to Aaron, "This is what the Lord spoke, [when He
said], 'I will be sanctified through those near to Me, and before all
the people I will be glorified.' " And Aaron was silent.
Rashi's commentary states,
And fire went forth: Rabbi Eliezer says: Aaron’s sons died only
because they rendered halachic decisions in the presence of Moses,
their teacher. Rabbi Ishmael says: [They died because] they had
entered the sanctuary after having drunk wine. The proof is that after
their death, [Scripture] admonished the survivors that they may not
enter the sanctuary after having drunk wine. This is analogous to a
king who had a faithful attendant. [When he found him standing at
tavern entrances, he severed his head in silence and appointed another
attendant in his place. We would not know why he put the first to
death, but for his enjoining the second thus, “You must not enter the
doorway of taverns,” from which we know that for such a reason he had
put the first one to death. Thus [it is said], “And fire went forth
from before the Lord and consumed them, and they died before the
Lord.” But we would not know why they [Nadab and Abihu] died, but for
His commanding Aaron, “Do not drink wine that will lead to
intoxication.” We know from this that they died precisely on account
of the wine. For this reason Scripture showed love to Aaron by
directing the divine utterance to him alone, thus, “Do not drink wine
that will lead to intoxication,”] as recounted in Vayikra Rabbah
The Lord tells Aaron in vs. 9,
Do not drink wine that will lead to intoxication, neither you nor
your sons with you, when you go into the Tent of Meeting, so that you
shall not die. [This is] an eternal statute for your generations.
The implication, from Rashi's comments, is that 2 sons have already died because they drank wine and became intoxicated, and didn't sanctify the Lord in the performance of their duties, when the oil of consecration was upon them, and they were dressed in the garments of their priestly office.
The Lord is to be sanctified, especially amongst the priesthood. To act presumptuously or carelessly is to provoke the Lord to "break out against you" as in Num. 18:1
And the Lord said unto Aaron, Thou and thy sons and thy father's house
with thee shall bear the iniquity of the sanctuary: and thou and thy
sons with thee shall bear the iniquity of your priesthood.