Die Doku sagt

For alternate function outputs, the port must be configured in Alternate Function Output mode (Push-Pull or Open-Drain).
For bidirectional Alternate Functions, the port bit must be configured in Alternate Function Output mode (Push-Pull or Open-Drain). In this case the input driver is configured in input floating mode
Wenn ich deinen Code + Kommentare gerade richtig deute sind deine Pins aber im Pull-Up, oder ist das eine Zusatzfunktion bei STM?!

Was für eine Variante des Chips hast du, die Doku sagt die Variante mit 36 Pins hat dieses Remap nicht
10: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (not available on 36-pin package)