This is a question that seems to come up every other month or so. I am not an expert but I will share what I have learned based on my own homework and I hope this can help, as it is a challenge that all reef keepers must learn to control for long term success. I myself have struggled with this balance as well and found many very short answers with anecdotal cures that didn't help me in the long run.
To put it simply, phosphates are directly linked to the food. Where nitrates are linked to to anything that releases ammonia like decaying fish food, dead animals, fish poop, and uriune. Nitrates are end result of the ammonia/nitrogen cycle.
Dried foods are naturally higher in phosphates since they are essentially concentrated natural/whole foods. Every living thing shrimp/algae/fish/humans/grass/trees is made up at the molecular level of phosphorous, it is what binds DNA strands together and creates the cell walls of every living cell. So if you dry out and concentrate those living things (IE make pellets or flakes) you will produce a food that is naturally higher in phosphates. This is why frozen foods are generally lower in phosphates and dried food are usually higher in phosphates. Frozen food just isn't as concentrated and generally contains less fillers. Fillers like wheat, potato starch, dried gluten meal...yeah really this stuff is in dried fish foods. I am sure my wrasse really needs that potato starch in his diet. I look at pellet and flake foods as something quick and easy to feed when I am in a rush or something to put in an autofeeder when I am out of town. They are essentially the hot dog and potato chips of fish feeding. I actually enjoy feeding my fish fresh and frozen foods since it is an interaction that I get to have with them. I spent a lot of money on those little guys I don't want them to hide all of the time. All of my fish now recognize me as the feeder and when I move around the living room they follow me around. When I sit and watch TV they stare at me. When I walk through the front door they come out to greet me.
Another common source for both nitrates and phosphates is tap water. So exhausted or worn out RODI filters can also be an issue. One more phosphate source that is often overlooked and easily avoided is low grade activated carbon. Some cheaper activated carbons use phosphates in the manufacturing process so they can actually release phosphates into the system. This is more common in peletized carbon so just do your homework or stick to a brand that is specifically made for reef aquariums.
Like Jimbo said before the challenge in phosphate reduction is that the phosphates bind to our substrates like rock, sand, filter socks, sponges and bio media like bio plates and cubes. The phosphate will essentially maintain an equilibrium between the substrate and the water column. The only way to get the phosphates out of the substrate is to have the phosphates in the water column low enough for long enough for the substrate to release them essentially finding a lower equilibrium. For this you will need a filtration media specifically designed to remove phosphates fro the water like GFO or aluminum sulphate, or start dosing Lantham Chloride(LC). If you want to start dosing LC do your homework as it can crash/poison your tank if not done properly. I think Jimbo has some experience with this method so he may be able to give you some pointers. You can also set up a macro algae refugium or algae reactor to remove phosphate but just keep in mind that this will also reduce nitrates and usually faster than it will drop phosphate.
I don't have as much info for nitrates as they are just not as complex of a subject. As stated earlier nitrates are the end result of the ammonia/nitrification cycle. Anything that releases ammonia will raise nitrates. So in my head I just sort of consider the two as the same thing with nitrates just being detoxified ammonia. As long as you have a sufficiently sized biofilter ammonia shouldn't be an issue after your biofilter has matured. During the first 6mo. or so ammonia can still be an issue and should be monitored. After that I have found that dead things and over feeding just cause crazy rapid nitrate spikes. I actually have an aquaintence who doses ammonia to keep his nitrate levels up, this is a discussion for another time though. Nitrates can be removed in many ways like water changes, carbon dosing, refugiums, algae turf scrubbers, algea reactors, sulpher denitrators, etc. The most effective way IMO is through the use of a macroalgae refugium. Just need a light and chamber to grow algae in.
Water changes can reduce nitrates and phosphates to some degree but are fairly ineffective at correcting levels once they raise to problem levels. The reason for this being that when doing a water change you are generally just changing 10%-20% of the water at a time. So if you have 30ppm of nitrate and .30 phosphate and do a 10% water change you have only dropped the levels to 28ppm nitrate and .28ppm phosphate. When you consider these numbers it becomes clear that something more must be done and water changes alone are not a good long term management strategy for these nutrient pollutants.
The main thing that I have learned about controlling both nitrates and phosphates is that it is a balance between import and export. What you import through food and supplements needs to have an equal removal source otherwise the numbers will rise. If your export means are too effective the numbers can bottom out and cause issues like dino bloom or coral bleaching. The best way to handle both of these nutrients/pollutants is to never let them get out of check in the first place.
Sorry for such a wordy answer. I just find that the subject of nutrient pollution comes up frequently and many new comers look for just a simple answer. The answer is just that a simple one doesn't really exist and it is a balance that really needs to be understood for success in the hobby.
Sent from my SM-G973U using Tapatalk