Japanese students walk to school in primary school and secondary school, although in high school they often take trains because they choose where they want to go and thus the campus can be farther from home. This also gives them more independence, since they can take trains rather than having their parents drive them.
Primary school students use randoseru, which are stiff leather backpacks, shown above. They are much sturdier than American backpacks, and are meant to last much longer: from the first year of primary school until the 6th grade. However, they are also much more expensive than American backpacks.
While I haven’t seen very many anime with primary school students, many anime settings are school-centered, so I have definitely noticed that in many animes the students walk to school.
Notice high school students (Keima and Elsi) and secondary school students (Tsuna and Haru) don’t have the same backpacks as the primary school students. This is also true in actual Japanese culture.