Words get borrowed into the languages not necessarily from the languages they originated in, not necessarily keeping their meaning, not necessarily the way they originally sounded and not necessarily once.
In each separate case there is usually some kind of logic: e.g. you can trace step by step how Ancient Greek ἐλέφας (source of English "elephant") ultimately became Russian верблюд ("camel"), or how гиацинт and яхонт are both from a common Greek source, but it's an ad-hoc logic every time.
As for томат, банан etc., they were borrowed from French where they are pronounced in almost the same way as they are in Russian, and батат is most probably from Neapolitan or other southern Italian idiom.
Words borrowed from Spanish either directly or through English (торнадо, авокадо etc.) are neuter and indeclinable, and keep the final -о.