In your current approach, when the pattern matches you are first printing a
and then set it to the value of the current line.
The effect of this is that a
always has the value of the previous line. If the match is on the first line, you will print an empty string as a has no value yet.
Besides remembering the current line in a
and printing it in the next iteration, you also have to print the current line $0
when the pattern matches.
awk '/pattern/ {
if (a) print a
print $0
}
{
a=$0
}' file
If the value of a can also be an empty string or evaluate numerically to zero as pointed out in the comments by Ed Morton, you can start printing a
from the second row on.
awk '
/regexp/ {
if(FNR>1) { print a }
print $0
}
{
a=$0
}' file