I think Screenrant explains it best(I highlighted the more important points.)
As of the 3.0.0 update for Pokémon HOME, which adds compatibility with Pokémon Scarlet and Violet, a new restriction has been added in the form of an ability reset, in addition to the pre-existing move reset. These restrictions mean that, when a Pokémon is transferred between games through HOME, their abilities and moves will not be carried over, so movesets and ability changes will often have to be made on an individual basis between different games. However, while the restrictions might seem mostly straightforward, there are a few particulars to keep in mind.
In addition to the Pokédex restrictions of recent Pokémon games, which mean that, for example, only some Pokémon can be transferred to Scarlet and Violet, transferring Pokémon to or from certain games will also reset their moves. A Pokémon being transferred to or from Legends: Arceus or Brilliant Diamond and Shining Pearl will not retain its original moveset, and will have to have its moves re-learned. However, if that same Pokémon is then transferred back to its original game, HOME will keep track of the different movesets, and change the moves accordingly whenever that Pokémon is moved again between those games.
Abilities work mostly the same, but with some key differences. If a Pokémon's ability is changed through the use of an Ability Capsule or Ability Patch outside the game that Pokémon is originally from, the ability will be reset to whichever ability it originally had when it's transferred to other games, and will need to be changed again if a player wants the Pokémon to have the different ability in another game. Like with moves, however, HOME will keep track of games where a Pokémon's ability is changed, and the Pokémon will retain its changed ability if it's transferred back to the game where it was changed.
Overall, the move and ability resets mean that a Pokémon's characteristics will not remain entirely consistent across different games when transferring through HOME. While stats and stat-affecting attributes like natures and EVs will carry over, in many cases moves and abilities will have to be managed on a game-to-game basis - especially in cases where a move's distribution has been changed. For example, while the move Scald is commonly distributed across many Water-type Pokémon in Sword and Shield, Scarlet and Violet removes from every Pokémon except for Volcanion, meaning that players will need to find another move to replace it when transferring to those games.
Notably, the 3.0.0 update for HOME also comes with the addition of the Move Reminder, which allows a Pokémon being transferred to a game to re-learn any move available to them in the game that the Pokémon is being transferred to. This can only be done when the Pokémon is being moved from a HOME box to a box in a specific game, and serves as a quicker, more convenient way to get a Pokémon's moves in order than teaching the Pokémon its moves in-game. While convenient, however, the Move Reminder is still subject to the move limitations of the game that the Pokémon is being transferred to.
Source Basically , if you transfer a Pokémon to a different game, their entire moveset will be changed. If you move them back into the original game, the movesets will put back to normal. You can ONLY relearn moves that the Pokémon can learn in that region via the new Move Reminder.
“ If I connect to a different game on my Switch, will their movesets go back to what they used to be before I connected to Brilliant Diamond?”
I don’t exactly know what you mean by this. If you mean by transferred your Pokémon back, then the answer is yes. Hope this helped!