When the tray closes by itself right after you open it, this usually means there is some debris blocking the mechanism the tray rides on. Either that or you’re pressing the eject button more than once (unlikely though).
There are a couple options. If it’s in warranty, you can call Microsoft and tell them you have a malfunctioning disc tray… they should be able to replace it. If not, well then you can either open up your system and try to clean things out or do what I’ve seen others do in the past—when the tray tries to close, grab it and keep it open until it stops trying to close.
It’s a strange method and you run the risk of breaking the tray altogether but it’s worth a shot if there’s no other way you can get it fixed. You might also try sticking some air duster in there and hope you blow the dust/debris out of the way. Again, I don’t recommend grabbing the tray but I’ve seen it work before.