Code:
# awk -vfs=" | " -vf1=", " -vlast=3 '
function sumforsum(c){lc=0;for(i=c;i>=(c-last);i--){d[x++]=$i;lc++}}
function sumforcheck(j){cmp="";for(i=1;i<(j-last);i++)if(i==1)cmp=cmp $i;else cmp=cmp FS $i;}
function compx(){sumforcheck(NF);sumforsum(NF);fcmp=cmp;if(getline){sumforcheck(NF)} else {writex();printf "%s","\n";exit}}
function combinedprntf(i,f){for(j=i;j<x;j+=last+1)printf "%s%s%s%s",d[j],FS,d[j-1],f;printf "%s%s%s",d[j],FS,d[j-1]}
function stdprntf(i,f){if(i==last){x=x-lc;l="ok"}for(j=i;j<x;j+=last+1)printf "%s%s",d[j],f;;if(l=="ok")printf "%s",d[j];}
function loopx(){while(fcmp==cmp){compx();;};writex();;x=0;;;sumforsum(NF)}
function writex(){split(fcmp,a);for(i=1;i<=length(a);i++){printf "%s%s",a[i],FS;if(i==1||i==length(a))printf "%s",fs;}
for(k=0;k<last;k++){if(k==0){f=FS;stdprntf(last,f);printf "%s",fs}if(k==1){;combinedprntf(2,f1);printf "%s",fs}if(k==last-1){stdprntf(0,f1);}}}
{compx();loopx();printf "%s","\n";}' infile
A_AA960715 | leucine-rich repeat-containing protein | GO:0006952 GO:0016491 | defense response, oxidoreductase activity | A, C
A_AA960716 | protein | F F F | defense response, SON BU2, SON BU2 | E, GG, GG
A_AA960718 | protein | T T T | SON BU2, SON BU2, SON BU2 | GG, GG, GG
A_AA960717 | protein | X X X X | defense response, metabolic process, oxidoreductase activity, signal transduction | H, I, J, K
A_AA960719 | protein | Y Y | signal transduction, signal transduction | WW, WW
A_AA960717 | protein | Q Q Q | signal transduction, signal transduction, signal transduction | K, K, K