Let me explain it to you in plain words what has happened in your situation. It has happened to me many times before and it was hard for me to digest it because I believe it is a stupid rule but it is what it is.
Lets say you have $10000 cash in your account and have no position and lets assume that commission is zero to make it simpler. On Monday you buy 100 shares of stock which is $100 per share you buy $10000 worth of stock. That transaction goes well. Either that day or a month later, (does not matter when), the stock goes to $110 and you sell your shares so your account should have $11000. That money will be settled in your account in 3 business days (pay attention). Just 2 hours after you sold the stock drops to $100 and then you decide to buy back 100 shares so you put the order. Your order goes through. In the second trade the broker lends you money to buy the shares because you still don't have money(remember your money will be available after 3 business days) so in the second trade you are using your broker's money because he is trusting you (hahaha). Now the rule is that you cannot sell your second trade's position before paying the money that you borrowed from your broker. This situation does not happen in real life (non stock related stuff). The person who lends you money should be happy if you sell your item and pay him back but not in the stock market. Please let me know if it sinks now. If you sell your second trade, that would be OK but you have done a day trade and you cannot do 3 day trades in 3 business days.