Thanks for asking a question on www.thisisyourbible.com
If you read Leviticus 10:1,2 it is clear that Nadab and Abihu did not follow the prescription of the Law when coming before God. It seems that they suffered a harsh punishment considering the crime of which they were guilty except that:
Their great sin was that of contempt for God's law and His place of worship. For this sin they paid with their lives. Their punishment, though severe, was well deserved and set a bench-mark ever after for the service of the priests before God.
I hope you have found this helpful.