The κ-Newtonian and κ-Carrollian algebras and their noncommutative spacetimes