I tried to buy perfume from a vending machine
I tried to buy perfume from a vending machine, but it was out of odor.
This joke is a pun. Odor in this joke is used as a pun for the word "order". Out of order means not functioning properly, so this joke is saying that the vending machine was not functioning properly.
To function properly, a vending machine that vends perfume would definitely need to have something that smelled inside of it, however the normal definition of odor is "a strong unpleasant smell", so this pun is really quite a bad one... unless this joke has a second meaning, and they are also subtly insulting the smell of perfume, in the which case they were probably a little bit too subtle, because I doubt that most people would have gotten that meaning from the joke.