Hi Pedro,
When you execute a query, then iterate over the result with a For Each, the Platform uses a database cursor, fetching records one-by-one for each iteration. This conserves memory, as the result set doesn't need to be loaded in its entirety (though might be slightly slower, as for each record communication with the database is needed).
When you re-iterate the query result, the Platform can no longer use a cursor (it's not possible to reset the cursor apparently), so the entire result set needs to be fetched from the database first. Also, when indexing the result set, more than one record at a time may be needed, and using a cursor is no longer possible.
As for your question, "where this happens", the short answer is "wherever you create code that re-iterates or uses indexes". The recommendation says "don't do this, unless it is strictly necessary", so if you don't do it, it doesn't happen.