how would I factor x to the thrid + 3x squared - x -3

I got (x+3) (x squared -1) and my teacher marked me wrong.

x^3 + 3x^2 - x - 3

looks like grouping will work

= x^2(x+3) - (x+3)
= (x + 3)(x^2 - 1)
= (x+3)(x+1)(x-1)

Your teacher should not have marked it "wrong", it was just incomplete.
If the question said, factor fully or something like that, then you must have my answer.
If it simply said , factor, you were correct, since you factored it.