erase(x,y) actualy erases y characters starting at position x, not from position x to position y.
In the first example (where x=start of string) these are the same, but in the second it finds the position of "MyCoolNumbers" as the starting point, and then uses the position of the first "~~" as the count.
you want to use
1 2 3
int start = s.find("MyCoolNumbers");
int count = s.find(("~~",start)-start;
s.erase(start , count);
Note that in a more generic case you would want to check start >=0 and count >0 to ensure you had a range to delete.