This is "the cycle", in short. Fish poop, pee, and exhale. This causes ammonia. Ammonia is poisonous to fish. After a while, bacteria grow that comsume the ammonia and convert it into nitrite. This is also poisonous to fish. Then another bacteria comes along and converts the nitrite into nitrate. The nitrate is less harmfull to the fish until it builds up into higher concentrations. The way to remove the nitrate in most cases is to do a water change. That is the basic "cycle". Now when you drained and cleaned the pond, you probably killed most of the bacteria. They live on the surfaces of the pond liner, rocks, plants, and in the filter. They love oxygen rich environments as well. So now you have nothing filtering out the poisonous ammonia. Your pond will also probably turn pea soup green for a while, which I would not panic over. I would also not pour anit bacteria or anti algae into the pond. They will actually work against you and the cycle.