The swipl-win.exe console doesn’t support 24-bit direct color. Seems it neither supports the 8-bit color model, so you only have the classical 16 ANSI colors.
To get more, some hacking is required in src/win32/console/console.c
This works as expected: ?- ansi_format([fg(yellow)], '~w', ['bananas']), nl, ansi_format([fg(blue)], '~w', ['blue berries']).
Looking at the code in ansi_term.pl i see that the color options in this case seem to be black, red, green, yellow, blue, magenta, cyan and white. Or are there additional colors?
Nope. These are the good old 16 color ansi palette (8 colors in normal and high intensity mode). Since then there is the 256 model and the direct color model, but neither is implemented in the swipl-win.exe console. It shouldn’t be rocket science to do so …