Hi, I am working on an H1b visa and living in VA where I pay taxes and my wife is a resident of MD, We are buying a house in MD as Co-owners, how do taxes work for me?

As the loan is in my name though I won't stay at our house in MD, we will be paying property taxes in MD. First is it legal to buy a house in another state on h1b and second how are my taxes going to work?