Four people have died after heavy rain and flooding in Japan, with thousands more left stranded.