Because whitespace matters, basically, as you deal with inline elements. The <input>
s in the source code are separated by whitespace; the ones injected (by JS) aren't.
There are various solutions to this, most of them listed in this question (I'd suggest checking them all instead of just the accepted one). Those, in turn, can be grouped into...
1) 'tag clash', removing whitespace in between elements. It can be done like this...
<input type="button" class="some_class"
/><input type="button" class="some_class"
/><input type="button" class="some_class" />
... or like this...
<input type="button" class="some_class" /><!--
--><input type="button" class="some_class" /><!--
--><input type="button" class="some_class" />
2) 'style collapse' - leaving whitespace in place, but making it invisible. In absense of the simple solution, usually this involves creating some container around those inline elements, and setting its font-size and line-height to 0.
The downside of this approach is that you'll have to restore these properties for the elements inside that container.
3) 'floating' - turning all the inline elements into blocks, applying 'float' style to them. This way the whitespace will go away visually too.