Live in PA Work in MD

I live in PA but I work in MD. My W2 shows that PA state taxes were withheld. When I did my taxes it now says I owe thousands in MD taxes. I worked in MD before as a PA resident and never paid MD taxes. What am I doing wrong?