Fungus ants are attracted to rotting roots, decomposing plant material, sour soil. The adults lay their eggs on top of the soil, and they hatch in about 4 days. Fungus gnats like to eat organic matter, so they steal nutrients away from your plants. You can get rid of them by topping the soil with sand, silica, which also aids in stalk or stem growth. This will prevent the laying of new larvae. Neem oil can be used to suffocate the adults. If gnats are flying around your plant, assume they are fungus gnats and get rid of them.
There is no relationship between what attracts gnats and aphids, other than your plants. Sooty mold can attract aphids.