In my English class my Teacher said I cannot use "Last two years ago...", so what should I use correctly?
*Last two years ago is incorrect because it combines two constructions with different senses:
Ago is a preposition which, unusually, follows its object. That object is a measurement of distance in time and designates a time point (though it may be a rather fuzzy point) at that distance in the past. It's used to designate the date or time at which an eventuality occurred:
Two years ago I answered a question about stative verbs. —that is, I answered the question in September of 2014. (It was actually on September 15, but as I said, the 'point' is fairly fuzzy.)
The last (not bare last) are a determiner and an adjective†; when this group is attached to a nominal which designates a measurement of distance in time it designates a timespan of that length reaching from the past right up to the present. The entire noun phrase is used with a preposition such as in or for or since to designate the period during which one or more eventualities occurred:
In the last two years I have answered thirteen questions tagged perfect-constructions. —that is, during the period running from September, 2014 up to the present I answered thirteen questions.
Note that the noun phrase the last [TIME MEASUREMENT] can also be used without a preposition to designate the period itself:
The last two years have gone by very quickly.
Combining last and ago, your phrase tries to characterize two years simultaneously as both a time point and a time span. You have to pick one or the other.
† As Ahmad suggests, it is arguable that last* in temporal contexts should be considered a determinative, and the last a Determiner Phrase*—but that doesn't affect the point at issue here.
"ago" is used to specify a time point in the past when something happened. Before "ago" you need a time period like "two years" or "10 minutes" to specify how long ago it happend:
5 minutes ago
an hour ago
a long time ago
some time ago
two years ago
bare "last" without "the" is used as a determiner (opposite of next) to specify a time.
last year, last night, last week
last can also be used as an adjective to point to something that is at the end in a sequence.
the last person
the last chapter of the book
the last two years
the last year
Note, when you point to the last two years, you point to a specific time period ("two years") which is the last one. It spans from two years ago to the present and you usually use a "present perfect" tense with it
I have been learning English in the last two years.
This time period can also be used as the subject or object of the sentence.
The last two years have been very difficult for my family.