On finitely generated projective and flat ideals in commutative rings