I have bought most of my tech books online, partially because of discounts, but more often for the reviews. Bookstores, because they own the stock, rarely have any indication of what the purchasers thought of the books. To get that kind of feedback, I have to go online, and once there, well, it is often easier to just buy from where I am.
A deeper issue, though, is the age of stock. Bookstores near me are very bad about keeping their stock up to date, or getting in the latest and greatest. Amazon and B&N, on the other hand, note upcoming editions. Thus, if I spot the fourth edition of a title on the shelf, I have to drop by somebody's website, just to see if there is a more recent version out there that applies to my task.
So, how can a brick and mortar store fight back? Primarily by providing a service that earns the sales. The Tattered Cover has topic managers that actually know what stock is current, and that keep tabs on what is up and coming. Barnes and Noble should consider linking their online reviews to the brick and mortar store, then hyping it. Having sales staff that I want to talk to might help - I pay $4 a cup for Starbucks lattes because I like the people there. A bookstore can earn business the same way.
This is not terribly cheap, but it is needed for a brick and mortar store to justify its usually higher prices.