Hi Rusland,
"
In accordance with" means the refered to item complies with a rule, law, someone's wishes, etc.
"
According to" means the item has been mentioned by someone, in a document, contract, etc.
There may be other meanings (and ambiguity) but if you stick to these uses you should be ok.
The reason for the perceived interchangability is because some sentences can take both meanings. For example:
In accordance with document 4827, held at the townhall, planning permission has been applied for. (Document 4827 sets out the rules for planning applications.)
According to document 4827, held at the townhall, planning permission has been applied for. (Document 4827 is a proof of receipt of the planning application.)