You are forgetting something Doom created this world... So, he must have created these gems, also... So, they work in this "universe"...
But Doom must also have created a backdoor for safety regarding the use of these Infinity Gems... Doom would not be stupid enough to create something powerful enough to destroy him
...Unless, these gems were created by the Beyonders...