You need to terminate your array with NULL character as
char string2[5]={'1','2','a','b','\0'};
When you are doing the scanf(), string1 is stored in next memory so it is printing string2 with string1. It will print upto it gets \0 so its Undefined Behavior