Cramping in early pregnancy

Why does cramping occur in early pregnancy? 5weeks feels like period cramps