Knotted solutions for linear and nonlinear theories: electromagnetism and fluid dynamics