2009 iMac automatically ejecting DVD
That usually happens when the disc is damaged or dirty and can’t be mounted. Physically inspect the surface of your disc for scratches or residue, and if necessary clean it with a microfiber cloth (wiping radially, outward). It’s okay to use water or a damp cloth if necessary, but avoid harsh chemicals. And of course wipe your disc dry before trying again.

If this doesn’t work, make sure your DVD drive isn’t the culprit by inserting another DVD and making sure it mounts properly.