How do I solve these problems when flashing Samsung Galaxy J5 (SM-J510FN)?
The file system may be broken or something. Or the file system are read-only for some reasons...

You should know that flashing with Odin and "normal" (AP)  firmware doesn't wipe the phone, it just upgrade the system but leave the user data partition untouched.

Assuming there is no hardware failure (damaged eMMC), such errors can be corrected by flashing a "repair" firmware which contains a script that wipe everything in the phone.

Try searching for "4 files firmware" on the internet then flash with Odin. Should work now.