The OS X Dock is a convenient tool for storing commonly accessed applications, documents, folders, and other items like Web links. While you can customize the contents of Dock, there may be times when changes you make to the Dock will be reverted, either instantly or after a brief period of time.
The only items in the Dock that should not be removable are the Finder icon and the Trash icons, but if other items either do not add or are stuck in the Dock then you may be experiencing one of two problems.
Items you store in the Dock are set in the Dock's preferences and database files, and if for some reason these files are corrupted then any changes you make to the Dock could be reverted. Usually this type of problem results in an instant inability to modify the Dock, so once you add and item or remove one the changes will instantly revert.
The most straightforward way to address this problem is to locate and remove the Dock's settings files, which are located in the /username/Library/Preferences/ folder and are called "com.apple.dock.plist" and "com.apple.dock.db." Remove these files from the preferences folder and then log out and log back in to relaunch the Dock (or type "killall Dock" in the Terminal utility).
Keep in mind that doing this will revert the Dock's settings to default, so be sure to make a note of your Dock's contents (a screenshot by pressing Option-Command-3 will do nicely) before resetting it so you can restore it again.
Corruption in sync services
If your Dock items are reverting after a few minutes or hours, then it is likely the you have a synchronization service running that is updating the Dock items. If you have synchronized to MobileMe and then you can try either disabling the Dock Items sync in the MobileMe system preferences or reset the sync data for Dock Items.
To do this, go to the MobileMe system preferences and click the "Advanced..." button. Then click the "Reset Sync Data..." button at the bottom of the computer list, and you will see the sync reset window appear. In this window, select "Dock Items" from the drop-down menu and then choose whether you want to replace the items on MobileMe with those on your current systems, or vice versa.
Once this is done, close the window and manually sync the system to ensure all items on MobileMe and your Dock are up to date, and then try your modifications again.
Beside settings and sync options, the Dock does support a variety of hidden settings for freezing certain items in place. This is done by setting the "contents-immutable" option for items, which can be reverted by running the following command in the Terminal:
defaults write com.apple.dock contents-immutable -bool false; killall Dock