Least-squares finite element formulations for viscous incompressible and compressible fluid flows