Igor Matanović scored two of three late Freiburg goals in a dramatic conclusion to the Baden-Württemberg derby with VfB Stuttgart.