Scribal convention versus scribal error
Experts know. Some homophone substitutions are very common and widely accepted and they have a name "通假字". If you want to understand Classical Chinese, you'll have to know these common 通假字s. And of course plain mistakes also exist. If you read enough, you'll know which are acceptable and which are just mistakes.