Restore Applications folder to dock
I'm assuming you dragged this icon, from the Sidebar of a Finder window…
That, as you discovered, will remove it from the Sidebar rather than add it to the Dock.



You can get that back from Finder Menu > Prefs > Sidebar.
Re-check the Applications icon



To then add Applications to the dock, start by clicking the sidebar element you just restored, in any Finder window.
Then drag the icon from the top of that window down into the right side of the Dock [I've moved my window right to the bottom of the screen to get these pics]