Issues with knockback function/script

I’m trying to get a knockback function in my game to work. I’ve Googled a lot, but none of the solutions work so far.

This code is what I’m using:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCollision : MonoBehaviour
{
    public float knockbackForce = 10f;
    public Rigidbody2D rb;
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Enemy")
        {
            Vector2 knockbackDirection = (rb.position - (Vector2)collision.transform.position).normalized;
            rb.AddForce(knockbackDirection * knockbackForce, ForceMode2D.Impulse);
            Debug.Log("Player hit by enemy");
        }
    }
}

I attached this script to my player character, but he’s not being knocked back.

I also want to make an animation event which will then run the knockback script when the enemy attacks the player (or vice versa) only when they are attacking. As I understand it, I create the animation event and then I run something like this, right?

void OnTriggerEnter2D(Collider2D other) 
{
    if (other.tag == "Enemy" || "Player")
    {
        // -> knockback logic here <-
    }
    controller.enabled = false; //this will disable your character controller
}

I’m still relatively new to Unity so while I understand some concepts I have difficulty getting them into practice.