The Emancipation Proclamation freed enslaved people living in areas controlled by the Confederacy.
This document could only be enforced within Confederate states, and not all of the American states wanted to be part of the Confederacy. This is the reason why this law didn't apply to them, and in the beginning, slavery was still allowed in such states.