You can't find the range in ALL cases by substituting into the function the end points of the domain. You need to find what the minimum and maximum the function will output given the domain.
The function

has a minimum of .75 at x = -.5
If we limit the domain to [0, 2] the range could be found by substituting the end points.
However, if the stated domain were [-1, 1], substituting the end points would give the result [1, 3], but the actual range is [.75, 3]
You can use the domain as a starting point, then determine if there is a minima or maxima that would be included.
I hope that helped.
Edited function to what I graphed, Thanks Jiten.