"why is there a time period of 12 in the "ema result" but not in the data.history for teh my_stock_series?"
The TA-lib functions generally return a series of values. They typically don't return a single value. So, in the case of the above example 'talib.EMA', the function accepts a series of prices and returns a series of exponential moving averages. The input data can be any length. The TA-lib functions will return a series which is the same length as the input data. So, in this case it will return a series of length 30. The first 12 elements of the series (ie 0 through 11) will be NaN but starting with the 12th element they will be the exponential moving averages of the previous 12 days data. If the data is shorter than the timeperiod, you will get a series of all NaN values.
One often just wants the latest value so that is why, in the example, it used the last value in the series to record using the [-1] notation.
As far as why grab more data than you need. Typically not necessary. However, it depends upon what you want to do. If you don't just want the last data value but instead really do want a series (maybe you are calculating RSI and want the average RSI over the last 5 days) then the data will be longer than the timeperiod.