The density issue isn't country wide, but about metro areas. See Spain: If you look at the entire country and divide by population, it looks like the one of the least dense countries in Europe. But what if instead we look at where people live? Get the population density of the square kilometer where each person lives, and divide by number of people, so completely empty space doesn't count for anything. Then you see Spaniards live in areas denser than Liechtenstein. And guess what? Spain has top notch public transport, including high speed rail, because every endpoint is dense. I am right now sitting in a town, population around 100k, with higher population density than New York's Upper East side. We don't even have that much public transport, because only the elderly and the disabled need it, given that I can be on any given edge of town by walking 2 kms. In your typical US suburb, that gets you nowhere.
So it's not country density, but population center density. Single family homes with yards and individual garages make public transport pretty bad, as the catchment rates of each stop just don't have enough people. Just put the people closer together, and have more farmland/forest around the town.