You are not assigning to a pointer, you are assigning to wherever that pointer is pointing.
Since your pointer is uninitialized it is not pointing at an assignable location, therefore you get a segmentation fault.
Compare this code
int b;
int* a;
a = &b; // assigning to a pointer
*a = 10; // now the pointer is pointing somewhere, so this is valid
cout << b; // print 10
Strictly speaking when you dereference an uninitialized pointer, your program has undefined behaviour, crashing with a segmentation fault and not displaying any error at all, are both possible consequences of undefined behaviour. This is illustrated by your second program, it also has undefined behaviour but it did not get a segmentation fault. This is how C++ works, there is no guarantee that bad programs will crash.