It's routine in many countries that refusing to obey lawful police orders is in itself some sort of offense. The officer was writing him a ticket (a minor penalty) for driving an unsafe vehicle, which it clearly was. He ordered Walt to stay in his car.
New Mexico law includes
66-7-4. Obedience to police officers.
No person shall willfully fail or refuse to comply with any lawful order or direction of any police officer invested by law with authority to direct, control or regulate traffic.
In addition to refusing to stay in his car, his behavior was belligerent and threatening towards the police officer, who is just a public official going about his duty. I don't want to be political, but people have endured far worse than pepper spray for less.