The halachah is that they may take only one can, as the other can does not belong to them. Taking an extra can is a violation of three mitzvos—the positive and negative commandments of hashavas aveidah, returning lost objects, as well as the negative commandment of “Do not steal.”
The person should call the owner of the machine and inquire how to return the extra can or how to pay for it. If the identity of the owner cannot be determined, and the machine is located in an area frequented primarily by Jews, they should affix a note to the machine describing what happened and include their contact information. If they already drank the soda, they still have to pay the owner the value, following the procedure described above. If the person still can’t reach the owner, they should record the details and the cost of the extra can, so in event that they are contacted by the owner they will know how much to pay him.
If all attempts to reach the owner have failed, the equivalent of the extra can should be given for tzarchei rabim, communal needs, to atone for the aveirah of stealing, as is done when one cannot identify the owner of goods that have been stolen.