Don't use tabs. Use spaces. At least when posting answers on Stack Overflow.
The eternal war between tabs and spaces is a silly one, they each have their purposes. Spaces are required to precisely line up identifiers in code, and I'm slightly OCD so I appreciate that. Tabs have the advantage of being configurable, so that you can have your text editor interpret a tab as 8 spaces and I can set mine to 2 spaces, and we're both happy. I therefore use tabs in languages where I don't care about lining things up (e.g. HTML and CSS), and spaces in languages where I do (e.g. C++). But more to the point, I've found that tabs just do not work well with the markdown interpreter Stack Exchange uses. I cannot tell you how many times I've cursed when trying to edit a poorly-formatted post that used tabs for indentation, rather than spaces. In fact, it seems there's almost a pattern: when questions are horribly formatted, they are almost always pasted in from a text editor that was set to use tabs, instead of converting tabs to spaces.
Of course, that doesn't mean you can't use the Tab key. I do it all the time, I have just configured it to insert 4 spaces when I press it. Much easier, and less wear and tear on my spacebar.
A lot of people, including Servy, recommend composing code in an external text editor, and then copying and pasting it to the answer box. I say pish-posh, mainly because it's fun to say, but also because I usually don't want to take the time to fire up another application just to compose a simple answer. Unless it's something I have to test, which is unusual with simple sample code snippets, I'll type it right into the answer box. Like you, I get extremely frustrated with the default handling of the Tab key.
There is a good reason for it. Again, like Servy points out, it is common convention in applications for the Tab key to switch focus between the various controls that receive input. Developers—and this includes web designers—should never override this behavior, as it may interfere with accessibility, particularly by users who do not use a mouse to navigate around a user interface.
But you—as a user—can customize this behavior. On Chrome, I use a couple of extensions to make my life easier:
balpha's stackexchange-tab-editing extension, which makes the Tab, Home, and Backspace keys in the post editor behave more like they do in text editors.
chrome-textarea-formatter, which makes any text box (of your choosing) on a web page behave more like one in a text editor. You activate this extension on-demand, by clicking an icon that appears in your browser's address bar. (Do make sure that you customize this one to insert 4 spaces upon presses of the Tab key, rather than inserting a literal tab.)
I'm sure that there are similar extensions for other browsers, but despite the Chrome team's best efforts, that's the only browser I use in Windows.
It is also worth pointing out that you can take advantage of the built-in "Code Format" feature of the markdown editor. Selecting a block of text and clicking the {}
button (or pressing Ctrl+K) will indent or unindent by 4 spaces. This is a lot faster than press either Tab or Backspace for each line. Unfortunately, there is no "increase indent" or "decrease indent" feature—all you get is a toggle. But there is a user script for that, too.