So you are setting
velocity to the returned value of
move_and_slide_with_snap. This value, a
Vector2, is the remainder of motion not travelled by
move_and_slide_with_snap; basically when your character is moving through the air and collides with the side of the platform,
move_and_slide_with_snap has moved as far left as it can go, but still has to go up, thus returning a value that might look like
Vector2(0, 4). Since the
Vector2.x is 0 but the
Vector2.y is greater 0, you stop moving left or right, and will continue to move upwards a bit.
A simple fix is to just apply that lateral speed to
velocity.x. Though, based on the GIF, if you are still holding
LEFT, your character-box might not be clearing the
CollisionShape2D of the platform, so it is simply going up, then dropping down.