A four-year-old boy has been freed from a vending machine in the Melbourne CBD, after his hand was stuck for about six hours.