because you set the velocity to a new value when you walk which overwrites the old jump value. You can fix this by putting the input_event in the _physics_process:
func _physics_process(delta) -> void:
# Gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Walking. If I delete this part, the jumping works as intended.
var walk_input = Input.get_axis("ui_left", "ui_right")
if is_on_floor():
velocity = get_floor_normal().rotated(deg_to_rad(90)) * walk_input * SPEED
if Input.is_action_pressed("ui_accept") and is_on_floor():
velocity += (Vector2.UP + get_floor_normal()) / 2 * JUMP_VELOCITY
move_and_slide()