When I was a kid I read a book about a boy who gets transported to a different planet.
The people are put in different domes, with different creatures. Main character either escapes to another dome or crashes in it. I can’t remember which. An old shaman type person takes him in and "trains" him in their ways. On occasion one of the "people" is chosen to eat a special fruit and some dirt, after which they genetically transform into another creature.
Main character later eats one of the fruits and transforms into the original species of the planet. That species has been extinct for a long time but robots are maintaining a preservative program for other species. The kid escapes back to Earth by convincing the robots that he really is one of the indigenous species and shuts the robots down. Afterwards he returns to human form by eating another fruit and some dirt from Earth.