If you are a VA resident, all your income belongs to VA and is taxed there. When you work in MD and pay taxes to MD, you are correct that you report those taxes on your VA return and they give you credit for them.
You then file a non-resident return to MD to get those taxes refunded to you, as you may still owe tax on your income to your home state of VA.
Click the link for more info to help you with living and working in multiple states.