Carrots grow in village farm plots and occur in shipwreck and pillager-outpost chests. Zombies can also drop them.
Using a carrot on farmland plants a crop. Harvesting mature crops supplies carrots for eating or replanting; Fortune can increase the harvest. Rabbits can damage carrot crops.
Carrots restore hunger when eaten. They attract and breed pigs and rabbits, can be traded to farmer villagers for emeralds, and can be composted.
Crafting uses include golden carrots, rabbit stew and carrots on sticks. These outputs are distinct items; the ordinary carrot remains the planting and food item.
Mojang dates the Java introduction to version 1.4.2; this is not a Bedrock introduction date. In Mojang's Bedrock zombie loot table, carrots belong to a rare-drop pool requiring a kill by a player or pet. That condition is Bedrock-specific evidence and does not establish Java drop probabilities.