Backward Reachability Analysis of Neural Feedback Loops: Techniques for Linear and Nonlinear Systems