In times of war or siege, Italian families would vacate their homes and rent apartments in safer areas. In order to protect themselves they would hire soldiers to sleep on the floor in shifts.
Ordinarily we would want to verify such stories before publishing them here as part of a phrase derivation. In this case though it isn't really important. The meaning of the phrase turns on the association in Italian folk-memory of mattresses with safety in wartime. The phrase wasn't well known outside of the USA and Italy prior to the Godfather movies. It was used there, and later in The Sopranos television series, to mean 'preparing for battle'. Whether or not the stories that originated it are true doesn't alter the fact that the screenwriters of those films used them in that context.
Mainly popularized by the film, "The Godfather."