This is how I understand it works:
One of if not the primary purpose of urea, urine, uric acid, excrement, defecation in most (all?) organisms is the removal of excess nitrogen (N) which is otherwise poisonous to a biological organism. Plant life contains a lot of fixed nitrogen (which is why plants work to reduce nitrogen problems in an aquarium.) But protein also is made up of fixed nitrogen as well. Most fish use the gills because that is how fish evolved (and because ammonia dispersal via gills is far more efficient and less costly biologically than defecation), but the source of the nitrogen is not from the gills or the water, it's from protein that is in the food fish eat. Terrestrial animals evolved differently (likely since using the lungs to excrete ammonia isn't a healthy method.)
(Undigested waste products are also removed that way and that is the essential purpose of the excretory and digestive systems.)
Food contains protein and protein contains nitrogen. Fish eating food, convert excess nitrogen into ammonia.
Without food, I'm unclear what the source of nitrogen is for a fish to excrete. Water is only H2O and so the source of the N (nitrogen) in ammonia afaik only comes from the protein in food. Even if it's the painfully slow degradation of muscle tissue within the fish from starvation and lack of food, it's a tiny fraction of what a healthy fish produces when fed properly.
So, my understanding is that if you don't feed the fish, you don't get any ammonia. As always, I'm looking for answers, so if someone wants to correct me, I'll thank you in advance.