The issue is the expression a?.startswith('0') results in null, so the null pointer exception isn't that the safe navigation operator isn't working, it's because the if statement can't handle a null.
You can't have null in an if statement.
ie. It would result in:
String a = null;
if (null && ('a' == 'a')) {
System.debug('t');
}
else {
System.debug('f');
}
You can test this by replacing a?.startswith('0') with a?.startswith('0') == true. The following code will work as you expect it to:
String a = null;
if (a?.startswith('0') == true && ('a' == 'a')) {
System.debug('t');
}
else {
System.debug('f');
}