Don’t name your variable rigidbody2D. This is the same name as an existing deprecated property on MonoBehaviour. Call it anything else and the script will work.
Assuming you do have a RigidyBody2D component on your object (I myself tend to miss this part quite often )
You may give it a force with a vector showing up using the AddForce function.
The generic version will always return the type passed in. That’s the whole point of the generic function and angle brackets. Casting is a total waste of time and performance.
The non generic version does return a component, and needs to be casted. But using the non generic version is limited to some special use cases. These are way beyond the OP at present.
Missing a RigidBody would throw a null reference error. Different problem.