The correct name for a “castle” is a “rook”. Castling is a move involving moving the king and a rook in a unique way. You can find references for this online.
Technically, as long as you’re operating within the legal maneuvers of the game, you can put the king in check whenever you want.
In the examples you mentioned (moving a queen/rook/bishop directly next to a king), you are free to do this as you please, however, the king may or may not be able to capture your piece. If you place your opponents king in check, and the king is able to capture your piece (more on that below), it was likely a legal, but senseless move (unless it was part of a grand strategy).
Your opponent’s king cannot capture your offending piece if your piece is protected by another one of your pieces. The king cannot “move into harm’s way” otherwise it would be committing suicide. It can only be captured/cornered by your pieces. This is one of the ways that the king differs from other pieces.
Generally, you should not place your opponents king in check just for the sake of checking the king. Otherwise, this becomes a wasted move.
Here are some valid reasons for placing the king in check, even though it may not result in an imminent checkmate:
- To force your opponent to move one of their defending pieces, to shield the king, resulting in a configuration you consider favorable.
- To force your opponent’s king to move to a location you consider more vulnerable/favorable
- To force your opponent’s king to move, so he can no longer castle.
I’m sure there are other reasons, but those are the three that come to mind.
For what it’s worth, using computer based Chess games is a good way to solidify your understanding of the legal moves, since they will not allow you to make illegal moves.
Have fun and good luck!