Small towns really do have programs to give away homes if you commit to remodeling them or tear them down. Even in bigger cities it isn't difficult to find abandoned properties.
(I'll also add: people see things like Cheap Houses Japan, and make incorrect assumptions about the state of the resale market. For a large portion of those "cheap" properties, you'd have to put in 2-3x the sales price just to make them livable. In other words, the owners are trying to solve their financial problem by dumping it on someone else who is more willing to deal with it. This could be appealing for someone who wants a vacation home and loves the area, but it's not a healthy housing market.)
But you’re talking more about markets where there is very little demand (due to declining population) for both new and used housing. Or homes that are in such a state of disrepair that it makes more sense to demolish them and rebuild from scratch.
Here’s one that I found in Takasaki with very little effort.
https://suumo.jp/chukoikkodate/gumma/sc_takasaki/nc_70960514...
Most of the houses being torn down are not what I would consider “perfectly serviceable”. There are usually serious issues such that the home isn’t worth saving.