I read this story 30+ years ago in grade school. A man crashes on an alien planet. He has a small amount of water and accidentally spills some, and the planet replicates it but it must destroy part of itself to do so. The man then finds some stale crumbs in his pocket, puts them in a trough, and the planet replicates them as well, but it's disgusting to eat. The man eventually decides that his situation is hopeless, so he lays down to die on a table in a hot room and thinks he can at least give back to the planet some of the nutrients it sacrificed for him. He falls asleep, and when he awakens, he has been transformed into an alien creature that is perfectly suited and adapted to live on the planet without discomfort to himself or damage the planet.
"Enchanted Village" (aka "The Enchanted Village" aka "The Sands of Mars") by A. E. van Vogt, perhaps his best short story, reprinted many times; originally published in Other Worlds Science Stories, July 1950, available at the Internet Archive. Here is an excerpt:
"I've won!" thought Jenner. "The village has found a way!"
After a while he remembered something and crawled to the bathroom. Cautiously, watching the ceiling, he eased himself backward into the shower stall. The yellowish spray came down, cool and delightful.
Ecstatically Jenner wriggled his four-foot tail and lifted his long snout to let the thin streams of liquid wash away the food impurities that clung to his sharp teeth.
Then he waddled out to bask in the sun and listen to the timeless music.